﻿using Microsoft.AspNetCore.Http;

using Microsoft.EntityFrameworkCore;
using Models.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilsCache;
using UtilsORM;
using UtilsORM.MySqlData;

namespace GatewayServerService.Data
{
    public class DBIotDeviceLinkageConditionCache
    {
        public DBIotDeviceLinkageConditionCache()
        {

        }


        public List<iot_device_linkage_condition> GetLinkage_Condition(string lguid)
        {
            List<iot_device_linkage_condition> conditions = UtilMemoryCacheHelper.StringGet<List<iot_device_linkage_condition>>("iot_device_linkage_condition" + lguid);
            if (conditions == null)
            {
                EFYihongIotContext ef = new EFYihongIotContext();
                conditions = ef.iot_device_linkage_condition.Where(c => c.lc_l_guid == lguid && c.lc_status == 0).ToList();
                if (conditions != null)
                {
                    UtilMemoryCacheHelper.StringSet("iot_device_linkage_condition" + lguid, conditions, 1);
                }
                ef.Dispose();
            }
            return conditions;
        }
    }
}
